//
// Created by liushuai on 18-7-15.
//

#include "Time.hpp"
#include <iostream>
Time::Time() {
    minuts = 0;
    hours = 0;
}
Time::Time(int h, int m) {
    minuts = m;
    hours = h;
}
void Time::reset(int h, int m) {
    minuts = m;
    hours = h;
}
void Time::show() const {
    using std::cout;
    cout<<"Hour: "<<hours<<" Minuts: "<<minuts<<"\n";
}
void Time::addmin(int m) {
    minuts += m;
}
void Time::addhour(int h) {
    hours += h;
}
Time Time::operator+(const Time &t) const {
    Time T;
    T.minuts = minuts+t.minuts;
    T.hours = hours+t.hours+T.minuts/60;
    T.minuts %= 60;
    return T;
}
Time Time::operator-(const Time &t) const {
    Time T;
    int tot1,tot2;
    tot1 = t.minuts+60*t.hours;
    tot2 = minuts+60*hours;
    T.minuts = (tot2-tot1)%60;
    T.hours = (tot2-tot1)/60;
    return T;
}
Time Time::operator*(const double x) const {
    Time T;
    long total = hours*x*60+minuts*x;
    T.hours = total/60;
    T.minuts = total%60;
    return T;
}